#!/usr/bin/python
#!c:\Python27\python.exe
#
######
#xunlei:
#AAhttp://im.baidu.com/install/BaiduHi.exeZZ
#Thunder://QUFodHRwOi8vaW0uYmFpZHUuY29tL2luc3RhbGwvQmFpZHVIaS5leGVaWg==
#kuaiche
#[FLASHGET]http://im.baidu.com/install/BaiduHi.exe[FLASHGET]
#Flashget://W0ZMQVNIR0VUXWh0dHA6Ly9pbS5iYWlkdS5jb20vaW5zdGFsbC9CYWlkdUhpLmV4ZVtGTEFTSEdFVF0=&
#xuanfeng
#aHR0cDovL2ltLmJhaWR1LmNvbS9pbnN0YWxsL0JhaWR1SGkuZXhl
#qqdl://aHR0cDovL2ltLmJhaWR1LmNvbS9pbnN0YWxsL0JhaWR1SGkuZXhl
#
#date is 2013-08-26 16:33:25 eblog.cc
###
import base64

def deciphering_base64(the_string,url_class):
    if url_class == "thunder":
        result_string = base64.decodestring(the_string)
        result_string = result_string[2:-2]
        print "the thunder real down url is: " + result_string
    if url_class == "flashget":
        result_string = base64.decodestring(the_string)
        result_string = result_string[10:-10]
        print "the flashget real down url is: " + result_string
    if url_class == "qqdl":
        result_string = base64.decodestring(the_string)
        print "the qqdl real down url is: " + result_string
    
def decide_url(des_string):
    if (des_string.lower().startswith("thunder://")):
        print "this string is xunlei"
        print des_string[10:]
        class_url = "thunder"
        des_string = des_string[10:]
        deciphering_base64(des_string,class_url)
        
    else:
        if (des_string.lower().startswith("flashget://")):
            print "this string is flashget"
            print des_string[11:-1]
            des_string = des_string[11:-1]
            class_url = "flashget"
            deciphering_base64(des_string, class_url)
        else:
            if (des_string.lower().startswith("qqdl://")):
                print "this string is qqdl"
                print des_string[7:]
                des_string = des_string[7:]
                class_url = "qqdl"
                deciphering_base64(des_string, class_url)
            else:
                print "the url is error please check"
        
if __name__ == '__main__':
    print "This program support Thunder Flashget and qqdl"
    print "please input ,convert to real down url!"
    some_string = raw_input("please input the down_url:")
    print "jie mi down url ing ...."
    decide_url(some_string)
    
